<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        /* box固定宽高 */
        .box {
            width: 200px;
            height: 200px;
            border: 1px solid #000;
            margin: 200px auto;
        }
        /* stage与box同宽高 */
        /* 六个面首先要定位在同一个位置 */
        .stage {
            position: relative;
            width: 200px;
            height: 200px;
            border: 1px solid #000;
             /* transform-style: preserve-3d; 被嵌套的子元素在父元素内呈现3D效果展示 */
            /* 设置内部子元素在3D空间进行展示 */
            transform-style: preserve-3d;
            /* 3D要给父级添加透视属性 */
            perspective: 5000px;
            /* 过渡 */
            transition: all 3s ease;
        }
        /* stage整体能旋转 */
       
        .stage:hover {
            transform: rotateX(360deg) rotateY(360deg);
            /* Google safari兼容 */
            -webkit-transform: rotateX(360deg) rotateY(360deg);
        }
        /* .stage的所有子级同样属性赋予 */
        .stage div {
            position: absolute;
            left: 0;
            top: 0;
            width: 200px;
            height: 200px;
            font: bold 80px/200px "arial";
            text-align: center;
        }
        /* 伪类选择器 */
        .stage div:nth-child(1) {
            background-color: rgba(255, 0, 0, 0.5);
            transform: translateZ(100px);
        }
        .stage div:nth-child(2) {
            background-color: rgba( 0,255, 0, 0.5);
            transform: rotateX(90deg) translateZ(100px);
        }
        .stage div:nth-child(3) {
            background-color: rgba( 0, 0,255, 0.5);
            transform: rotateX(180deg) translateZ(100px);
        }
        .stage div:nth-child(4) {
            background-color: rgba(255, 255, 0, 0.5);
            transform: rotateX(-90deg) translateZ(100px);
        }
        .stage div:nth-child(5) {
            background-color: rgba(255, 0, 255, 0.5);
            transform: rotateY(90deg) translateZ(100px);
        }
        .stage div:nth-child(6) {
            background-color: rgba( 0,255, 255, 0.5);
            transform: rotateY(-90deg) translateZ(100px);
        }
    </style>
</head>
<body>
    <!-- 正方体 -->
    <div class="box">
        <div class="stage">
            <!-- 正方体六个面 同父级.stage -->
             <div>1</div>
             <div>2</div>
             <div>3</div>
             <div>4</div>
             <div>5</div>
             <div>6</div>
        </div>
    </div>

    <!-- 
        safari兼容问题：
        在transform前添加-webkit-
    -->
</body>
</html>
